package itcast.web.servlet;

import itcast.domain.Build;
import itcast.domain.Outt;
import itcast.service.BuildService;
import itcast.service.OuttService;
import itcast.service.impl.BuildServiceImpl;
import itcast.service.impl.OuttServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/updateStudent_outServlet")
public class UpdateStudent_outServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //设置编码
        request.setCharacterEncoding("utf-8");
        //2.获取map
        Map<String,String[]> map=request.getParameterMap();
        //3.封装对象
        Outt outt=new Outt();
        try {
            BeanUtils.populate(outt,map);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        //调用Service
        OuttService service=new OuttServiceImpl();
        service.updateout_student(outt);
        //跳转到查询所有的Servlet
        response.sendRedirect(request.getContextPath()+"/student_outServlet");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request,response);
    }
}
